package com.office.shop.by.components;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by IntelliJ IDEA.
 * User: Олег Семенов
 * Date: 04.07.11
 * Time: 13:57
 * To change this template use File | Settings | File Templates.
 */
public class CImages {

    public static Bitmap fetchImage( String urlstr ) {
        try
        {
            URL url;
            url = new URL( urlstr );
            HttpURLConnection c = ( HttpURLConnection ) url.openConnection();
            c.setDoInput( true );
            c.connect();
            InputStream is = c.getInputStream();
            Bitmap img;
            img = BitmapFactory.decodeStream(is);
            return img;
        }
        catch ( MalformedURLException e )
        {

        }
        catch ( IOException e )
        {

        }
        return null;
    }
}
